package com.esri.core.internal.symbol.advanced;

import com.esri.core.geometry.SpatialReference;
import com.esri.core.internal.util.d;
import com.esri.core.map.Graphic;
import com.esri.core.symbol.advanced.Message;
import java.util.HashMap;

/* loaded from: classes.dex */
public class MessageProcessorInternal {
    private static final String d = "_ID";
    private static final String e = "_WKID";
    private static final String f = "_WKT";
    protected long a;
    String b;
    protected String c;
    private long g;
    private String[] h;
    private long i;
    private SpatialReference j = SpatialReference.create(4326);

    private static native String nativeCreateMessageFrom(long j, String str);

    private static native String nativeCreateMessageFromGraphicID(long j, int i);

    private static native long nativeCreateMessageProcessor(String str, long j, long j2, String str2, double d2);

    private static native String[] nativeGetDefaultSpatialReference(long j);

    private static native String[] nativeGetGraphic(long j, String str);

    private static native int nativeGetGraphicID(long j, String str);

    private static native String[] nativeGetMessageTypes(long j);

    private static native boolean nativeProcessMessage(long j, String str, String str2);

    private static native void nativeSetDefaultSpatialReference(long j, int i, String str);

    public MessageProcessorInternal(String str, long j, long j2, String str2, double d2) {
        this.a = -1L;
        this.b = str;
        this.g = j;
        this.c = str2;
        this.i = j2;
        this.a = nativeCreateMessageProcessor(str, j, j2, str2, d2);
    }

    public boolean a(Message message) {
        long j = this.a;
        if (j == -1) {
            return false;
        }
        return nativeProcessMessage(j, message.getID(), d.a(message.getProperties()));
    }

    public Message a(Graphic graphic) {
        Message message = new Message();
        long j = this.a;
        if (j == -1) {
            return message;
        }
        message.setProperties((HashMap) d.a(nativeCreateMessageFromGraphicID(j, graphic.getUid())));
        return message;
    }

    public Message a(String str) {
        Message message = new Message();
        long j = this.a;
        if (j == -1) {
            return message;
        }
        message.setProperties((HashMap) d.a(nativeCreateMessageFrom(j, str)));
        return message;
    }

    public SpatialReference a() {
        String[] nativeGetDefaultSpatialReference;
        long j = this.a;
        if (j == -1 || (nativeGetDefaultSpatialReference = nativeGetDefaultSpatialReference(j)) == null) {
            return null;
        }
        int parseInt = Integer.parseInt(nativeGetDefaultSpatialReference[0]);
        String str = nativeGetDefaultSpatialReference[1];
        if (parseInt > -1) {
            return SpatialReference.create(parseInt);
        }
        return SpatialReference.create(str);
    }

    public void a(SpatialReference spatialReference) {
        nativeSetDefaultSpatialReference(this.a, spatialReference.getID(), spatialReference.getText());
    }

    public long b() {
        return this.g;
    }

    public String[] c() {
        if (this.h == null) {
            this.h = nativeGetMessageTypes(this.a);
        }
        return this.h;
    }

    /* JADX WARN: Can't wrap try/catch for region: R(14:12|13|14|(11:39|40|(1:18)|19|(2:32|33)|(1:22)(1:31)|23|24|25|26|27)|16|(0)|19|(0)|(0)(0)|23|24|25|26|27) */
    /* JADX WARN: Code restructure failed: missing block: B:39:0x006f, code lost:
        r8 = move-exception;
     */
    /* JADX WARN: Code restructure failed: missing block: B:40:0x0070, code lost:
        r8.printStackTrace();
     */
    /* JADX WARN: Removed duplicated region for block: B:24:0x0042  */
    /* JADX WARN: Removed duplicated region for block: B:34:0x005b  */
    /* JADX WARN: Removed duplicated region for block: B:35:0x0060  */
    /* JADX WARN: Removed duplicated region for block: B:50:0x004b A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public com.esri.core.map.Graphic b(java.lang.String r8) {
        /*
            r7 = this;
            long r0 = r7.a
            int r0 = nativeGetGraphicID(r0, r8)
            r1 = 0
            if (r0 != 0) goto La
            return r1
        La:
            long r2 = r7.a
            java.lang.String[] r8 = nativeGetGraphic(r2, r8)
            int r2 = r8.length
            if (r2 != 0) goto L14
            return r1
        L14:
            r2 = 0
            r3 = r8[r2]
            if (r3 == 0) goto L7c
            int r4 = r3.length()
            if (r4 != 0) goto L20
            goto L7c
        L20:
            org.codehaus.jackson.JsonParser r3 = com.esri.core.internal.util.d.c(r3)     // Catch: java.io.IOException -> L78
            com.esri.core.geometry.MapGeometry r3 = com.esri.core.geometry.GeometryEngine.jsonToGeometry(r3)
            com.esri.core.geometry.Geometry r3 = r3.getGeometry()
            r4 = 1
            r4 = r8[r4]
            if (r4 == 0) goto L3f
            org.codehaus.jackson.JsonParser r4 = com.esri.core.internal.util.d.c(r4)     // Catch: java.lang.Exception -> L36 java.io.IOException -> L3b
            goto L40
        L36:
            r4 = move-exception
            r4.printStackTrace()
            goto L3f
        L3b:
            r4 = move-exception
            r4.printStackTrace()
        L3f:
            r4 = r1
        L40:
            if (r4 == 0) goto L46
            com.esri.core.symbol.Symbol r1 = com.esri.core.internal.util.d.i(r4)
        L46:
            r5 = 2
            r5 = r8[r5]
            if (r5 == 0) goto L59
            org.codehaus.jackson.JsonParser r4 = com.esri.core.internal.util.d.c(r5)     // Catch: java.lang.Exception -> L50 java.io.IOException -> L55
            goto L59
        L50:
            r6 = move-exception
            r6.printStackTrace()
            goto L59
        L55:
            r6 = move-exception
            r6.printStackTrace()
        L59:
            if (r4 == 0) goto L60
            java.util.Map r4 = com.esri.core.internal.util.d.a(r5)
            goto L65
        L60:
            java.util.HashMap r4 = new java.util.HashMap
            r4.<init>()
        L65:
            java.util.HashMap r4 = (java.util.HashMap) r4
            r5 = 4
            r8 = r8[r5]     // Catch: java.lang.Exception -> L6f
            int r2 = java.lang.Integer.parseInt(r8)     // Catch: java.lang.Exception -> L6f
            goto L73
        L6f:
            r8 = move-exception
            r8.printStackTrace()
        L73:
            com.esri.core.map.Graphic r8 = com.esri.core.map.FeatureUtil.newGraphic(r0, r3, r1, r4, r2)
            return r8
        L78:
            r8 = move-exception
            r8.printStackTrace()
        L7c:
            return r1
        */
        throw new UnsupportedOperationException("Method not decompiled: com.esri.core.internal.symbol.advanced.MessageProcessorInternal.b(java.lang.String):com.esri.core.map.Graphic");
    }
}
